package com.zyl.musicdemo.activitys;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.os.Parcelable;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zyl.musicdemo.R;
import com.zyl.musicdemo.adapter.SongAdapter;

import java.util.ArrayList;

import static com.zyl.musicdemo.adapter.AlbumAdapter.ALBUM_NAME;
import static com.zyl.musicdemo.adapter.AlbumAdapter.SONG_BASES;

public class SongListActivity extends BaseActivity {
    TextView tvAlbumName;
    RecyclerView recyclerViewSongList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_song_list);
        initView();
    }

    private void initView() {
        initNavBar(true, "专辑列表", false);
        tvAlbumName = findViewById(R.id.tv_album_name);
        recyclerViewSongList = findViewById(R.id.recyclerView_song_list);

        Bundle bundle = getIntent().getExtras();
        String albumName = bundle.getString(ALBUM_NAME);
        tvAlbumName.setText(albumName);

        ArrayList parcelableArrayList = bundle.getParcelableArrayList(SONG_BASES);

        SongAdapter songAdapter = new SongAdapter(parcelableArrayList, null);
        recyclerViewSongList.setAdapter(songAdapter);
        recyclerViewSongList.setLayoutManager(new LinearLayoutManager(this));
    }
}